home *** CD-ROM | disk | FTP | other *** search
- /*
- COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
- All rights reserved
- */
-
- /* Icon Resource Picker */
-
- /* This is the Icon resource picker. This picker is very similar to all other pickers.
- The general scheme is that a List structure is created whose cells
- contain the ID's of this resource type. A drawproc is installed in the List
- record which is called to display the resource. Obviously, graphical resources
- are drawn as is, but descriptions of other types can be displayed also (usually
- in a one-dimensional list). */
-
- #include <types.h>
- #include <memory.h>
- #include <menus.h>
- #include <resources.h>
- #include <lists.h>
-
- #include "ResEd.h"
-
- #define listCellSizeH 0x38
- #define listCellSizeV 0x42
-
- /* Needs to be 2 wide so that I can always tell a 2 dimensional list from a normal text list. */
- #define minIconsPerRow 2
- #define ICONMinWindowWidth (minIconsPerRow * listCellSizeH) + theScrollBar
- #define ICONMinWindowHeight listCellSizeV
-
- #define ICONResourceSize 128
-
-
- /* Used only for editors. */
- pascal void EditBirth(Handle thing, ParentHandle dad)
- {
- #pragma unused (thing, dad)
- }
-
- /* *********************************************************************************** */
-
- /* Returns the width and the iconsPerRow. */
- short GetWidth (short *iconsPerRow)
- {
- short width;
-
- width = PickStdWidth();
- if (width > ICONMinWindowWidth) {
- *iconsPerRow = (width - theScrollBar) / listCellSizeH;
- width = (*iconsPerRow * listCellSizeH) + theScrollBar;
- }
- else {
- width = ICONMinWindowWidth;
- *iconsPerRow = minIconsPerRow;
- }
- return width;
- }
-
- /* *********************************************************************************** */
-
- short GetHeight (void)
- {
- short height;
-
- height = PickStdHeight();
- if (height > ICONMinWindowHeight) {
- height = (height / listCellSizeV) * listCellSizeV;
- }
- else {
- height = ICONMinWindowHeight;
- }
- return height;
- }
-
- /* *********************************************************************************** */
-
- pascal void PickBirth(ResType t, ParentHandle dad)
- {
- PickHandle pick;
- PickPtr p; /* temp ptr for *pick */
- short iconsPerRow,
- width;
-
-
- pick = (PickHandle)NewHandle(sizeof(PickRec));
-
- p = *pick;
-
- p->father = dad; /* Back ptr to dad */
- p->rType = t; /* Resource type that I understand */
- p->viewBy = viewBySpecial; /* Special means we have our own LDEF to draw the icons */
- p->ldefType = t; /* Which LDEF do we use? */
- p->cellSize.h = listCellSizeH; /* Set the size of the cell. */
- p->cellSize.v = listCellSizeV;
-
- width = GetWidth (&iconsPerRow); /* Also sets iconsPerRow */
-
- // Setup the list and create the window.
- if (!DoPickBirth(false, true, width, GetHeight(), iconsPerRow, ResEdID(), pick)) {
- DisposHandle ((Handle)pick); // Error
- }
- else {
- (*pick)->rSize = ICONResourceSize;
- }
- }
- /* *********************************************************************************** */
-
- /* Everything except the grow box is taken care of for us by PickEvent. */
- pascal void DoEvent(EventRecord *evt, PickHandle pick)
- {
- WindowPtr windPtr;
-
- /* Must do our own grow box manipulation so that the min size is set correctly. */
- if ((evt->what == mouseDown) && (FindWindow(evt->where, &windPtr) == inGrow)) {
- GrowMyWindow (ICONMinWindowWidth, ICONMinWindowHeight, windPtr, (*pick)->instances);
- }
- else {
- PickEvent(evt, pick);
- }
- }
-
- /* *********************************************************************************** */
-
- /* Everything is taken care of for us by PickInfoUp */
- pascal void DoInfoUpdate(short oldID, short newID, PickHandle pick)
- {
- PickInfoUp(oldID, newID, pick);
- }
-
- /* *********************************************************************************** */
-
- pascal Boolean IsThisYours (Handle thing, PickHandle pick)
-
- {
- #pragma unused (thing, pick)
- return false;
- }
-
- /* *********************************************************************************** */
-
- pascal void DoMenu(short menu, short item, PickHandle pick)
- {
- /* Everything is taken care of for us by PickMenu. */
- PickMenu(true, menu, item, pick);
- }
-